/*!
 * Ext JS Library 3.3.0
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
/**
 * @class pivot.AxisGrid
 * @extends Ext.grid.EditorGridPanel
 * Grid used to control the dimensions in a PivotGrid axis
 */
var measures = {
	id:'measures_grid',
	title:'指标',
	iconCls:'measure',
	xtype:'grid',
	ddGroup: 'measureGridDD',
	enableDragDrop:true,
	enableHdMenu:false,
	enableColumnMove:false,
	autoScroll: true,
	tbar:['->','-',{
		iconCls: 'add',
		text:'自定义',
		handler: function() {
			Ext.getCmp('zhibiao_message').evObject = null;
			Ext.getCmp('measureLabel').setValue('');
			Ext.getCmp('measureExpress').setValue('');
			Ext.getCmp('editPanel').expand();
			Ext.getCmp('editPanel').setActiveTab(0);
		}
	},'-',{
		iconCls: 'delete',
		text:'批量删除',
		handler: function() {
			var grid = Ext.getCmp('measures_grid');
			var records = grid.getSelectionModel().getSelections();
			for(var i=0;i<records.length;i++){
				grid.getStore().remove(records[i]);
			}
		}
	}],
    store: new Ext.data.Store({
    	 autoLoad:true,
    	 data:[],
    	 reader: new Ext.data.ArrayReader({}, [{name: 'name'},{name: 'code'}])
    }),
    cm: new Ext.grid.ColumnModel([
        {	id:'name',
        	header: "指标名",
        	dataIndex: 'name',
        	renderer:function(value){   
            	return "<div ext:qtip='"+value+"'>"+value+"</div>";
        	}
        },
        {	id:'code',
        	header: "指标代码",
        	dataIndex: 'code',
        	hidden:true
        },
        {
            xtype: 'actioncolumn',
            width: 30,
            icon   : getRootPath() + '/ext3.1/fileOperate/images/icons/edit.gif',
            scope  : this,
            handler: function(grid, rowIndex, colIndex) {
                var data  = grid.getStore().getAt(rowIndex).data;
                //绑定修改对象
				Ext.getCmp('zhibiao_message').evObject=grid.getStore().getAt(rowIndex);
				Ext.getCmp('measureLabel').setValue(data.name);
				Ext.getCmp('measureExpress').setValue(data.code);
				Ext.getCmp('editPanel').expand();
				Ext.getCmp('editPanel').setActiveTab(0);
        	},
            tooltip: '编辑',
            editable: false
        }
    ]),
    stripeRows: true,
    autoExpandColumn: 'name',
	listeners:{render:function(){
		this.header.on("mouseover",function(){
			Ext.getCmp('accordion_config').layout.setActiveItem(0);
		});
	}}
};

